package icegps.com.pingdj.activity.settingactivity;

import android.widget.ImageView;

import butterknife.BindView;
import icegps.com.pingdj.R;
import icegps.com.pingdj.activity.BaseActivity;
import icegps.com.pingdj.bean.DeviceStatus;
import icegps.com.pingdj.bean.LocationStatus;
import icegps.com.pingdj.utils.UnitUtils;
import icegps.com.pingdj.view.ValueTextView;

/**
 * Created by 111 on 2018/3/20.
 */

public class ControlTestActivity extends BaseActivity {
    @BindView(R.id.iv_main_action)
    ImageView ivMainAction;
    @BindView(R.id.iv_deputy_action)
    ImageView ivDeputyAction;
    @BindView(R.id.tv_main_current_height)
    ValueTextView tvMainCurrentHeight;
    @BindView(R.id.tv_deputy_current_height)
    ValueTextView tvDeputyCurrentHeight;

    @Override
    protected String setTitle() {
        return getString(R.string.control_test);
    }

    @Override
    protected void init() {
    }


    @Override
    protected int setLayout() {
        return R.layout.activity_control_test;
    }

    @Override
    public void onAnalysisHexLocationData(LocationStatus locationStatus) {
        super.onAnalysisHexLocationData(locationStatus);
        double altitude = locationStatus.getAltitude();
        double altitude2 = locationStatus.getAltitude2();

        tvMainCurrentHeight.setText(UnitUtils.HEIGHT, deviceStatus.getHeight(), altitude);
        tvDeputyCurrentHeight.setText(UnitUtils.HEIGHT, deviceStatus.getHeight(), altitude2);


    }

    @Override
    public void onAnalysisAscDeviceStatus(DeviceStatus deviceStatus) {
        super.onAnalysisAscDeviceStatus(deviceStatus);
        setIvSrc(ivDeputyAction, this.deviceStatus.getControlTwo());
        setIvSrc(ivMainAction, this.deviceStatus.getControlOne());
    }

    public void setIvSrc(ImageView iv, int action) {
        switch (action) {
            case 0:
            case 1:
                iv.setImageResource(R.drawable.svg_no_action);
                break;
            case 2:
                iv.setImageResource(R.drawable.svg_down);
                break;
            case 3:
                iv.setImageResource(R.drawable.svg_up);
                break;
        }
    }

}
